home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / DoTasks.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  29.1 KB  |  737 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    DoTasks.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.17>     12/6/93    KTA        Marked DoCloseApp().
  19. #    <1.0.16>     12/2/93    KTA        DOSetupApp() - Changed output when aboutBox not tested, and
  20. #                                    aligned the header, added gDoSetupAppHook1 and 2 and added
  21. #                                    gDoCloseAppHook1 and 2. Removed all calls to DoSpecialTest().
  22. #    <1.0.15>    11/19/93    NAGA        modify TCS Format
  23. #    <1.0.14>     9/29/93    KTA        DoWindow() - Changed one output line to read, 'Scrolling will
  24. #                                    not be tested in DoWindow().'
  25. #    <1.0.13>     9/22/93    KTA        DoSetUpApp() - Bug Fix gSetUpForSaveDoc was accidentally renamed
  26. #                                    gSetUpForSaveDoc.
  27. #    <1.0.12>     9/13/93    KTA        Updated TestLevel specification.
  28. #    <1.0.11>      9/9/93    KTA        DoSetUpApp() - Changed output line so it does not say 'About to
  29. #                                    …'
  30. #    <1.0.10>     8/30/93    KTA        Updated task headers and parameters.
  31. #     <1.0.9>     8/25/93    KTA        Added support for parity checking the TCS stack.
  32. #     <1.0.8>     7/30/93    KTA        DoFiles() - only call revert if ModifyDocument was successful.
  33. #     <1.0.7>     7/19/93    KTA        Updates for FindWindow() to handle descriptors.
  34. #     <1.0.6>     7/14/93    KTA        International Support: see DoFiles(), DoSetupApp(), and
  35. #                                    DoCloseApp().
  36. #        <1+>     5/21/93    NAGA    Adding header and porting old files to follow new standards
  37. #
  38. # ****************************************************************************
  39. #
  40.  
  41. ########################################################################
  42. #                            External libraries 
  43. #=======================================================================
  44. Libraries "OutPut.Lib","Font.Lib","StandardFile.Lib","TCS.Lib","Draw.Lib","Print.Lib","LaunchQuit.Lib","Misc.Lib","TargetCheck.Lib", "DA.Lib","UserInterface.Lib";
  45.  
  46.  
  47. #########################################################################
  48. #                        DoDraw( pTestMethod, pSpecifier, pNumTimes )
  49. #========================================================================
  50. # Author:        Kevin Avoy
  51. # Description:    This task is a high level task which controls the amount and
  52. #                type of draw testing which will be automatically performed (based upon
  53. #                predefined application specific data structures).  
  54. # Parameters:    pTestMethod - the method of testing desired.
  55. #                            1 - random object will be generated <pNumtimes> times.
  56. #                            2 - a random object will be generated for all tools
  57. #                                defined in the gToolList.
  58. #                pSpecifier - (String, integer, descriptor) window pSpecifier in
  59. #                            which drawing will occur.
  60. #                pNumTimes - (integer) number of times to perform the <pTestMethod>.
  61. # Task references : A number of global undefined task references have been provided 
  62. #                    to allow scriptwriters the ability to customize calls to DoDraw();
  63. #                        gDoDrawHook1 - prior to any drawing.
  64. #                        gDoDrawHook2 - after drawing each individual object
  65. #                        gDoDrawHook3 - after completion of drawing all objects
  66. # Returns:        Nothing
  67. # Examples:        DoDraw(1,1,1)
  68. # Assumptions:    Data Structures are set up correctly (see the HitchHiker's guide for details)
  69. # Notes:        If the pTestMethod parameter is not explicitly passed in it
  70. #                can be set by defining the global gDrawLevel. gDrawLevel can
  71. #                be an integer or a list.  If gDrawLevel is an integer it will be
  72. #                used as the pTestMethod input parameter. If gDrawLevel is a list
  73. #                the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
  74. #========================================================================
  75. # History:
  76. # KTA    7/30/93     Changed name of gSetUpDoDraw -> gDoDrawHook1, changed name of 
  77. #                 gClearDoDraw -> gDoDrawHook3, Added gDoDrawHook2
  78. # KTA    8/25/93     Added ability to set gDrawLevel to a list
  79. #########################################################################
  80. TASK DoDraw(pTestMethod := -1, pSpecifier := 0, pNumTimes := 1 )
  81. begin
  82.     global gDrawLevel, gToolList;
  83.     
  84.     if (global gDebugFlag)
  85.     begin
  86.         println "DoDraw() input paramters pTestMethod - {pTestMethod}, pSpecifier - {pSpecifier}, mu,Objects - {pNumTimes}";
  87.         println " gDrawLevel - ", gDrawLevel;
  88.         
  89.     end;
  90.     if (pTestMethod = -1)
  91.     begin
  92.         if (typeOf(gDrawLevel) = 'list')
  93.         begin
  94.             pTestMethod := gDrawLevel[1];
  95.             pNumTimes := gDrawLevel[2];
  96.         end;
  97.         else
  98.             pTestMethod := gDrawLevel;
  99.     end;
  100.     
  101.     if (pTestMethod)
  102.     begin
  103.         if (global gDoDrawHook1)
  104.             call (gDoDrawHook1);
  105.         if (pTestMethod = 1)                # Totally Random Object
  106.         begin
  107.             Println "------- DoDraw - pTestMethod (1) ('{pNumTimes}' -  Random structure(s)) --------";
  108.             for i := 1  to pNumTimes
  109.             begin
  110.                 theObject := {'Random','Random','Random','Random','Random'};
  111.                 DrawObject(theObject, pSpecifier);
  112.                 If(global gDoDrawHook2)
  113.                     call(gDoDrawHook2);
  114.             end;
  115.         end;
  116.         else if (pTestMethod = 2)                # Random structure for all tools
  117.         begin
  118.             Println "------- DoDraw - pTestMethod (2) (Random structure for all tools) {pNumTimes} Times--------";
  119.             for i := 1 to pNumTimes
  120.             begin
  121.                 for toolNum := 1 to card(gToolList) 
  122.                 begin 
  123.                     theObject := {'Random','Random','Random','Random','Random'};
  124.                     theTool := gToolList[toolNum];
  125.                     # Insert the tool description into the object structure 
  126.                     # so the object knows how to draw itself
  127.                     theObject := InsertElemStruct(theTool, theObject);
  128.                     DrawObject(theObject, pSpecifier);
  129.                     If(global gDoDrawHook2)
  130.                         call(gDoDrawHook2);
  131.                 end;
  132.             end;
  133.         end; 
  134.     end;
  135.     else
  136.         Println "-------- DoDraw is turned - OFF ---------------";
  137.  
  138.         Println "-----------------------------------------------";
  139.         Println;
  140.     if global gDoDrawHook3
  141.         call (gDoDrawHook3);
  142. end; # DoDraw()
  143.  
  144. #########################################################################
  145. #        DoWindow( pTestMethod, pSpecifier, pRestoreWindow, pNumTimes )
  146. #========================================================================
  147. # Author:        Kevin Avoy
  148. # Description:    This task is a high level task which controls the amount and
  149. #                type of window testing which will be automatically performed.  
  150. # Parameters:    pTestMethod - the method of testing desired.
  151. #                            1 - a less complete window test (functionlist build 
  152. #                                dynamically based on gDoWindowList see below)
  153. #                            2 - complete window test scrolling, sizing, dragging, zooming.
  154. #                pSpecifier - (String, integer, descriptor) window pSpecifier for 
  155. #                            to be exercised.
  156. #                pRestoreWindow - Boolean - indicates whether or not to restore 
  157. #                                the window to it's original condition.
  158. #                pNumTimes - (integer) number of times to perform the <pTestMethod>.
  159. # Returns:        Nothing
  160. # Examples:        DoWindow(1,0,0,2)
  161. # Assumptions:    
  162. # Notes:        For more info in what each test does see TestWindow() in 
  163. #                'UserInterface.lib'. 
  164. #                If the pTestMethod parameter is not explicitly passed in it
  165. #                can be set by defining the global gWindowLevel. gWindowLevel can
  166. #                be an integer or a list.  If gWindowLevel is an integer it will be
  167. #                used as the pTestMethod input parameter. If gWindowLevel is a list
  168. #                the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
  169. #
  170. #                A global, gDoWindowList, has been provided as a way to indicate
  171. #                which tests are available for a given application.
  172. #                NOTE: This is only valid if pTestWindow evaluates to 2.
  173. #                e.g. global gDoWindowList := {1,1,1,1};
  174. #                 Set each element to 1 or 0.  
  175. #                Flag for performing DoWindows tests as follows:
  176. #                 Element: 1 - Sizing
  177. #                         2 - Scrolling
  178. #                         3 - Dragging
  179. #                         4 - Zooming
  180. #
  181. #========================================================================
  182. # History:
  183. # KTA    9/29/93 Changed output to read "Scrolling will not be tested in DoWindow()."
  184. #########################################################################
  185. TASK DoWindow(pTestMethod := -1, pSpecifier := 0, pRestoreWindow := 0, pNumTimes := 1 )
  186. begin
  187.     global gWindowLevel, gNoScrollTest, gAppTitle, gDoWindowList;
  188.     if (pTestMethod = -1)
  189.     begin
  190.         if (typeOf(gWindowLevel) = 'list')
  191.         begin
  192.             pTestMethod := gWindowLevel[1];
  193.             pNumTimes := gWindowLevel[2];
  194.         end;
  195.         else
  196.             pTestMethod := gWindowLevel;
  197.     end;
  198.     
  199.     if (pTestMethod)
  200.     begin
  201.         if global gSetupDoWindow
  202.         call (gSetupDoWindow);
  203.  
  204.         if (pTestMethod = 1)                                                 ## Quicklook Window Tests
  205.         begin
  206.             if gDoWindowList
  207.             begin
  208.                 Println "------- DoWindow - pTestMethod (1) - (Quicklook Window Test)  {pNumTimes} times --------";
  209.                 WindowFunctionList := {}; # initialize list
  210.                 # build list dynamically based on gDoWindowList
  211.                 if gDoWindowList[1]
  212.                 begin
  213.                     WindowFunctionList := insert (2,1,WindowFunctionList); # insert 2 in position 1
  214.                     WindowFunctionList := insert (1,2,WindowFunctionList); # insert 1 in position 2
  215.                 end;
  216.                 else
  217.                     logstr('Sizing Windows not tested in DoWindow().');
  218.                     
  219.                 if gDoWindowList[2]
  220.                 begin
  221.                     NextPos := (card(WindowFunctionList) + 1);
  222.                     WindowFunctionList := insert (3,NextPos,WindowFunctionList); # insert 3 in next position
  223.                     NextPos := (card(WindowFunctionList) + 1);;
  224.                     WindowFunctionList := insert (7,NextPos,WindowFunctionList); # insert 7 in next position
  225.                 end;
  226.                 else
  227.                     logstr("Scrolling will not be tested in DoWindow().");
  228.                     
  229.                 if gDoWindowList[1]
  230.                 begin
  231.                     NextPos := (card(WindowFunctionList) + 1);
  232.                     WindowFunctionList := insert (13,NextPos,WindowFunctionList); # insert 13 in next position
  233.                 end;
  234.                 
  235.                 if gDoWindowList[3]
  236.                 begin
  237.                     NextPos := (card(WindowFunctionList) + 1);
  238.                     WindowFunctionList := insert (14,NextPos,WindowFunctionList); # insert 14 in next position
  239.                     NextPos := (card(WindowFunctionList) + 1);
  240.                     WindowFunctionList := insert (15,NextPos,WindowFunctionList); # insert 15 in next position
  241.                 end;
  242.                 else
  243.                     logstr('Dragging Windows not tested in DoWindow().');
  244.                     
  245.                 if gDoWindowList[4]
  246.                 begin
  247.                     NextPos := (card(WindowFunctionList) + 1);
  248.                     WindowFunctionList := insert (17,NextPos,WindowFunctionList); # insert 17 in next position
  249.                     NextPos := (card(WindowFunctionList) + 1);
  250.                     WindowFunctionList := insert (17,NextPos,WindowFunctionList); # insert 17 in next position
  251.                 end;
  252.                 else
  253.                     logstr('Zooming Windows not tested in DoWindow().');
  254.                     
  255.                 if gDoWindowList[1]
  256.                 begin
  257.                     NextPos := (card(WindowFunctionList) + 1);
  258.                     WindowFunctionList := insert (11,NextPos,WindowFunctionList); # insert 11 in next position
  259.                 end;
  260.                 
  261.                 TestWindow(pSpecifier,WindowFunctionList,pRestoreWindow,pNumTimes);
  262.             
  263.             end; # if gDoWindowList
  264.             else # if not gDoWindowList
  265.                 logstr('No global gDoWindowList defined so DoWindow() testing not done.');
  266.                 
  267.         end; # if (pTestMethod = 2)    
  268.         else if (pTestMethod = 2)                                            ## Complete Window Test
  269.         begin     
  270.             Println "------- DoWindow - pTestMethod (2) - (Complete Window Test) {pNumTimes} times--------";
  271.             TestWindow(pSpecifier,0, pRestoreWindow,pNumTimes);                #        Performs functions 1 through 17
  272.         end; # if (pTestMethod = 1)
  273.         
  274.         
  275.         else if(TypeOf(pTestMethod) = 'list')                ## Pass in your own Window test (see WindowTest() in the Window.Lib
  276.         begin
  277.             Println "------- DoWindow - pTestMethod 'list' - (Pass in your own) --------";
  278.             TestWindow(pSpecifier, pTestMethod, pRestoreWindow, pNumTimes);    
  279.         end;
  280.     end;
  281.     else
  282.         Println "-------- DoWindow is turned - OFF ---------------";
  283.  
  284.     Println "-----------------------------------------------";
  285.     Println;
  286. end; # DoWindow()
  287.  
  288.  
  289. #########################################################################
  290. #                        DoText(pTestMethod, pNumTimes)
  291. #========================================================================
  292. # Author:        KTA
  293. # Description:    This task is a high level task which controls the amount and
  294. #                type of font testing which will be automatically performed.  
  295. # Parameters:    pTestMethod - the method of testing desired.
  296. #                            1 - Random font test
  297. #                            2 - QuickLook font test
  298. #                            3 - WaterFall font test
  299. #                pNumTimes - (integer) number of times to perform the <pTestMethod>.
  300. #                            (not valid for WaterFall testing)
  301. # Returns:        nada
  302. # Examples:        DoText(2,3);
  303. # Assumptions:    global gFontList, gFontSizeList, gFontStyleList must be defined.
  304. # Notes:         If the pTestMethod parameter is not explicitly passed in it
  305. #                can be set by defining the global gFontLevel. gFontLevel can
  306. #                be an integer or a list.  If gFontLevel is an integer it will be
  307. #                used as the pTestMethod input parameter. If gFontLevel is a list
  308. #                the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
  309. #========================================================================
  310. # History:
  311. #
  312. #########################################################################
  313. TASK DoText(pTestMethod := -1, pNumTimes := 1)
  314. begin
  315.     returnVal := 0;
  316.     
  317.     if not(global gSetFont)        #Auto Initilize if not done
  318.         InitFonts();
  319.     global kQLFontTest,gFontLevel,gFontList, gFontSizeList, 
  320.     gFontStyleList,gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu,gtextStr,gFontObject;
  321.     if (pTestMethod = -1)
  322.     begin
  323.         if (typeOf(gFontLevel) = 'list')
  324.         begin
  325.             pTestMethod := gFontLevel[1];
  326.             pNumTimes := gFontLevel[2];
  327.         end;
  328.         else
  329.             pTestMethod := gFontLevel;        # Set pTestMethod to global gFontLevel
  330.     end;
  331.     Println "The gFontList := ", gFontList;
  332.     Println "The gFontSizeList := ", gFontSizeList;
  333.     Println "The gFontStyleList := ", gFontStyleList;
  334.  
  335.     if (pTestMethod)
  336.     begin
  337.         if global gSetupDoText
  338.             call (gSetupDoText);
  339.         if (pTestMethod = 1)                        # Random font testing
  340.         begin
  341.             Println "------- DoText - pTestMethod (1) ∂({pNumTimes}∂) random (with global gFontLists) --------";
  342.             for numRecords := 1 to pNumTimes    # Type random font records <gNumRandom> times
  343.             begin
  344.                 gFontObject := gFontObject + 1;  # Increment the object number for TCS info
  345.                 RandomRecord := RandomFontRecords();
  346.                 FontRecord := SetFontParams(RandomRecord,,gFontObject);
  347.                 if(FontRecord)
  348.                 begin
  349.                     TypeStr("{gtextStr} ");
  350.                     ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject);    # Match and report back what is actually selected
  351.                     Println "• - ",FontRecord;
  352.                     returnVal := FontRecord;
  353.                 end;
  354.                 else
  355.                     Println "NOTE: Couldn't complete FontRecord • - ", RandomRecord;
  356.             end;
  357.         end;
  358.         else if (pTestMethod = 2)                # Quicklook font testing
  359.         begin                                    # 1 random record for each font
  360.             Println "------- DoText - pTestMethod (2) - 1 record for each font in global gFontLists {pNumTimes} times--------";
  361.             for i := 1 to pNumTimes
  362.             begin
  363.                 for each FontItem in gFontList
  364.                 begin
  365.                     gFontObject := gFontObject + 1;  # Increment the object number for TCS info
  366.                     RandomRecord := RandomFontRecords({FontItem,"",""});
  367.                     FontRecord := SetFontParams(RandomRecord,,gFontObject);
  368.                     if(FontRecord)
  369.                     begin
  370.                         TypeStr("{gtextStr} ");                    
  371.                         ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject);    # Match and report back what is actually selected
  372.                         Println "• - ",FontRecord;
  373.                         returnVal := FontRecord;
  374.                     end;
  375.                     else
  376.                         Println "NOTE: Couldn't complete FontRecord • - ", RandomRecord;
  377.                 end;
  378.             end;    
  379.         end;
  380.         else if (pTestMethod = 3)                # WaterFall font testing
  381.         begin    
  382.             Println "------- DoText - pTestMethod (3) - WaterFall (with global gFontLists) --------";
  383.             WaterFallFontTest();
  384.             returnVal := 1;
  385.         end;
  386.     end;
  387.     Else
  388.         Println "-------- DoText is turned - OFF ---------------";
  389.     Println "-----------------------------------------------";
  390.     Println;
  391.     if global gClearDoText
  392.         call (gClearDoText);
  393.     Return(ReturnVal);
  394. end; # DoText()
  395.  
  396. #########################################################################
  397. #        DoFiles(pTestMethod, pFileName, pSaveAsFlag, pSelectOpen, pRevertMI )
  398. #========================================================================
  399. # Author:        KTA
  400. # Description:    This task is a high level task which controls the amount and
  401. #                type of file testing which will be automatically performed.
  402. # Parameters:    pTestMethod - Method of testing 
  403. #                            1 - All tests outlined below
  404. #                            2 - Save As/Replace, close, open.
  405. #                            3 - Save As/Cancel, Save, modify, revert.
  406. #                            4 - Save/Cancel,Save(unique), Save (same file name)/Replace,
  407. #                                Save (same file name)/create unique extension.
  408. #                            5 -    Save As/Cancel, Save
  409. #                pFileName - File name to use when saving file if none passed
  410. #                            a filename will be generated bassed on the 
  411. #                            applications name and the time.
  412. #                pSaveAsFlag - Valid for all Testmethods. Indicates whether 
  413. #                             selecting the Save As menuItem is necessary.
  414. #                                 1 - select Save As. HardCoded 'Save As'.
  415. #                                0 - Do not select SaveAs.
  416. #                                list - list containing ordinality of 'Save As' menuItem.
  417. #                            This parameter has been updated for international support.
  418. #                            Now it can also be a list which contains the ordinality of 
  419. #                            the Save As menuItem. If a it is a list then the Save As menuItem
  420. #                            will be selected using the contents of the list.
  421. #                            e.g. if pSaveAsFlag = {6,2}, the sixth menuitem from the 2nd menu will
  422. #                            be selected as the Save As menuItem.
  423. #                pSelectOpen - Only valid if <pTestMethod> evaluates to 2
  424. #                            0 - Don't select 'Open' or anything else
  425. #                            1 - Select 'Open' - hard coded
  426. #                            2 - Select 'Open' by way of keyboard equivelant 'o'.
  427. #                            list - list containing ordinality of 'Open' menuItem.
  428. #                pRevertMI - Only valid if <pTestMethod> evaluates to 3
  429. #                            '' - Hard coded 'Revert' menuItem will be selected
  430. #                            list - list containing ordinality of revert MenuItem
  431. # Returns:        nada
  432. # Examples:        DoFiles(2, "myFile", {6,2}, {4,2});            # Save, close, open.
  433. # Assumptions:    
  434. #========================================================================
  435. # History:
  436. # KTA 7/7/93     Added pSaveAsFlag to specify the SaveAs menuItem for SaveAs() - intl
  437. #                  Added pSelectOpen to specify the Open menuItem for OpenFile() - intl
  438. #                  Added pRevertMI to specify the Revert menuItem for Revert() - intl
  439. # KTA 7/30/93     Only call revert if ModifyDocument was successful
  440. #########################################################################
  441. TASK DoFiles(pTestMethod := -1,pFileName := "",pSaveAsFlag := 1, pSelectOpen := 2, pRevertMI := '')
  442. begin
  443.     global gLastSavedFile;
  444.  
  445.     if (pTestMethod)
  446.     begin
  447.         if (pTestMethod = 1)                    # All File tests
  448.         begin
  449.             Println "------- DoFiles - testMethod (1) - (All File tests) --------";
  450.             for i := 2 to 4
  451.                 DoFiles(i);
  452.         end;
  453.         else if (pTestMethod = 2)                # SaveFile, close it, open it.
  454.         begin
  455.             Println "------- DoFiles - testMethod (2) - (Save As/Replace, close it, open it) --------";
  456.             if (SaveAs(pFileName,1,pSaveAsFlag) = 1)    # if file saved, but no replace exist
  457.                 SaveAs(pFileName,1,pSaveAsFlag);            # Save as again, insures replace exist        
  458.             CloseWindow(,,0);                    
  459.             OpenFile(gLastSavedFile,pSelectOpen);
  460.         end;
  461.         else if (pTestMethod = 3)                # SaveFile, modify it, revert it.
  462.         begin
  463.             Println "------- DoFiles - testMethod (3) - (Save As/Cancel, Save file, modify it, revert it) --------";
  464.             CancelStandardFile(1,pSaveAsFlag);            # SaveAs/Cancel SelectButton('Cancel');
  465.             Save();
  466.             if(ModifyDocument())
  467.                 Revert(pRevertMI);
  468.         end;
  469.         else if (pTestMethod = 4)                # Save/Cancel, Save - uniqueName, SaveSameName-OverWrite, SaveSameName-AddExtension for unique
  470.         begin
  471.             Println "------- DoFiles - testMethod (4) - (Save/Cancel, Save - uniqueName, SaveSameName-OverWrite, SaveSameName-AddExtension for unique) --------";
  472.             CancelStandardFile(,pSaveAsFlag);                    # SaveAs/Cancel keyEq('.');
  473.             SaveAs(,0, pSaveAsFlag);                        ## Save - uniqueName            
  474.             SaveAs(gLastSavedFile,1, pSaveAsFlag);            ## SaveSameName-OverWrite
  475.             SaveAs(gLastSavedFile,0, pSaveAsFlag);            ## SaveSameName-AddExtension for unique     
  476.         end;
  477.         else if (pTestMethod = 5)                # SaveFile, modify it, revert it.
  478.         begin
  479.             Println "------- DoFiles - testMethod (5) - (Save As/Cancel, Save file) --------";
  480.             CancelStandardFile(1,pSaveAsFlag);                # SaveAs/Cancel SelectButton('Cancel');
  481.             Save();
  482.         end;
  483.     end;
  484.     else
  485.         Println "-------- DoFiles is turned - OFF ---------------";
  486.     Println "-----------------------------------------------";
  487.     Println;
  488. end;
  489.  
  490. #########################################################################
  491. #     DoSetUpApp(pDismissOpeningDialog, pDefaultWindowSpec, pNewDocPath,
  492. #  pDismissNewDocDialog,pScrapText, pScrapPict, pSaveDoc, pOpenDoc)
  493. #=======================================================================
  494. # Author:              ML
  495. #
  496. # Description:        Sets up app after launch.  Matches app, closes default
  497. #                    window, creates a new document, optionally pastes from scrap, 
  498. #                    saves document.
  499. #
  500. # Parameters:        pDismissOpeningDialog - 0    No opening dialog
  501. #                                               1    type return key
  502. #                                        'string' select button named {string}        
  503. #                    pDefaultWindowSpec -    if -1, no default window - don't close         
  504. #                                            if 0, close first document window
  505. #                                            if string, then it holds title of window
  506. #                                            if integer > 0, then it holds ordinality of window
  507. #                                            Descriptor -  window descriptor
  508. #                    pNewDocPath -            0    don't create new doc
  509. #                                          {list} - containing ordinality of 'New' menuItem
  510. #                                            
  511. #                    pDismissNewDocDialog -     0    No new doc dialog
  512. #                                               1    type return key
  513. #                                        'string' select button named {string}
  514. #                    pScrapText -            0    Don't call Scrapbook(global ScrapText)
  515. #                                            1    call Scrapbook(global ScrapText)
  516. #                    pScrapPict -            0    Don't call Scrapbook(global ScrapPict)
  517. #                                            1    call Scrapbook(global ScrapPict)
  518. #                    pSaveDoc    -                0    Don't save newly created doc via DoFiles(2)
  519. #                                            1    Save newly created doc via DoFiles(2)
  520. #                                          {list} - containing ordinality of Save As menuItem
  521. #                    pOpenDoc    -            0    Don't save select 'Open' menuitem
  522. #                                            1    Select 'open' menuItem - hardcoded
  523. #                                            2    - keyEq('o');
  524. #                                          {list} - containing ordinality of 'Open' menuItem
  525. #                    
  526. # Task references : A number of global undefined task references have been provided 
  527. #                    to allow scriptwriters the ability to customize calls to DoSetUpApp();
  528. #                        gCustomScrapText - instead of generic Scrapbook(kScrapTEXT)
  529. #                        gCustomScrapPict - instead of generic Scrapbook(kScrapPICT)
  530. #                        gSetUpForSaveDoc - To do any setup before calling DoFiles(2)
  531. # Returns:            None
  532. #
  533. # Example:            DoSetUpApp(0,1,{'New','File'},0,0,0,1)
  534. #=======================================================================
  535. # History:    
  536. # KTA     7/7/93    Added pOpenDoc parameter to pass the Open menuItem to OpenFile if needed (intl)
  537. #                 Slightly modified pNewDocPath (intl)
  538. # KTA     7/19/93    changed specifier so descriptor is not embedded in a list.
  539. # KTA    8/24/93    TCS Stack parity check
  540. # KTA    9/9/93    Changed output line so it does not say 'About to …'
  541. # KTA    12/1/93 Deleted call to DoSpecialTest() and added hooks gDoSetUpAppHook1, 
  542. #                gDoSetUpAppHook2
  543. #########################################################################
  544. TASK DoSetUpApp(pDismissOpeningDialog:=0, pDefaultWindowSpec:=0, pNewDocPath:={'New','File'},
  545. pDismissNewDocDialog:=0,pScrapText:=0, pScrapPict:=0, pSaveDoc:=1, pOpenDoc := 2)
  546. begin
  547.     If (global gDoSetUpAppHook1)
  548.         call (gDoSetUpAppHook1);
  549.     global gFileName,gApptitle,gSetUpScrapText,gSetUpScrapPict;
  550.     LogStr("The expected application is '{gAppTitle}'.");
  551.     MatchApplication(0);
  552.  
  553.     if (pDismissOpeningDialog)
  554.     begin
  555.         if (global gCustomOpeningDialog)     # if custom Opening dialog
  556.             Specifier := gCustomOpeningDialog;    # define global for DismissDialog
  557.         else 
  558.             Specifier := [window o:1 s:dialog];
  559.         if (findWindow(Specifier))            # no opening dialog if twitched to
  560.         begin
  561.             LogStr('Dismissing opening dialog');
  562.             TCSStart({ 1, global kTCSetAppSetup },"Dismiss opening dialog");
  563.             TCSEnd({ 1, global kTCSetAppSetup },DismissDialog(pDismissOpeningDialog,Specifier));
  564.         end;
  565.     end;
  566.         
  567.     If (global gDoSetUpAppHook2)
  568.         call (gDoSetUpAppHook2);
  569.     
  570.     if (pDefaultWindowSpec >= 0 or TypeOf(pDefaultWindowSpec) = 'string' 
  571.     or TypeOf(pDefaultWindowSpec) = 'descriptor')
  572.     begin
  573.     
  574.         if match [window o:1]!
  575.         begin
  576.         
  577.             if (pDefaultWindowSpec = 0)
  578.             begin
  579.                 if findwindow(0)
  580.                     CloseWindow();
  581.             end;
  582.             else
  583.             if FindWindow(pDefaultWindowSpec)
  584.                 CloseWindow(,,pDefaultWindowSpec);
  585.                 
  586.         end; # if match [window o:1]!
  587.     end; # if (pDefaultWindowSpec >= 0 or TypeOf(pDefaultWindowSpec) = 'string')
  588.             
  589.     if (pNewDocPath)
  590.     begin
  591.         TCSStart({ 1, global kTCSetNewDoc },"Select File - New...");
  592.         TCSEnd({ 1, global kTCSetNewDoc },SelectMenuItem(pNewDocPath[1], pNewDocPath[2]));    # Open a New Document
  593.     end;
  594.     
  595.     if (pDismissNewDocDialog)
  596.     begin
  597.         if (global gCustomNewDocDialog)     # if custom Opening dialog
  598.             Specifier := gCustomNewDocDialog;    # define global for DismissDialog
  599.         else 
  600.             Specifier := [window o:1 s:dialog];
  601.         if (findWindow(Specifier))            # no opening dialog if twitched to
  602.         begin
  603.             logstr('Dismissing new document dialog');
  604.             TCSStart({ 2, global kTCSetAppSetup },"Dismiss new document dialog");
  605.             TCSEnd({ 2, global kTCSetAppSetup }, DismissDialog(pDismissNewDocDialog, Specifier));
  606.         end;
  607.     end;
  608.     
  609.     if (pScrapText)
  610.     begin
  611.         if global gCustomScrapText                        # hook for custom scrap text
  612.             call (gCustomScrapText);
  613.         else
  614.         begin
  615.             Scrapbook(global kScrapTEXT);                # Paste TEXT from Scrapbook
  616.             #SpecialKey(returnKey , "Return Key");
  617.         end;
  618.     end; # if (pScrapText)
  619.     
  620.     if (pScrapPict)
  621.     begin
  622.         if global gCustomScrapPict                        # hook for custom scrap pict
  623.             call (gCustomScrapPict);
  624.         else
  625.             Scrapbook(global kscrapPict);
  626.     end; # if (pScrapPict)
  627.         
  628.     if (global gSetUpForSaveDoc)                            # hook to setup for Saving Document
  629.         call (gSetUpForSaveDoc);
  630.         
  631.     if (pSaveDoc)
  632.         DoFiles(2,gFileName, pSaveDoc, pOpenDoc);
  633.  
  634. end; # DoSetUpApp()
  635.  
  636. #########################################################################
  637. #     DoCloseApp(pSaveRevert, pDismissAboutBox, pPageSetup, pPrinter, pQuit)
  638. #=======================================================================
  639. # Author:              ML
  640. # Description:        Performs either DoFiles(3) or Dofiles(5), Selects and dismisses
  641. #                    the 'About' box, Selects and dismisses 'Page Setup', Selects and
  642. #                    dismisses 'Print', thenpQuits.
  643. # Parameters:        pSaveRevert -    0 - Save As/Cancel/Save, no modify/revert
  644. #                                    1 - Save As/Cancel/Save, modify/revert
  645. #                                   -1 - no Save As/Cancel/Save, no modify/revert
  646. #                                    {list} - International - two elements 
  647. #                                        1st element 
  648. #                                            list - list containing ordinality of 'Revert' menuItem.
  649. #                                            integer - Any of the pSaveRevert options listed above.
  650. #                                        2nd Element - should be set even if 1st element is 0
  651. #                                            list - list containing ordinality of 'Save As' menuItem.
  652. #                    pDismissAboutBox -  -1 - Don't do About Box test
  653. #                                        0 - Return key
  654. #                                        integer > 0     - Click in center of 
  655. #                                                        screen {integer} times
  656. #                                        String -  Select button named <string>
  657. #                    pPageSetup -            
  658. #                                        0 - Don't do default PageSetup()
  659. #                                        1 - Do default PageSetup()
  660. #                                        list - list containing ordinality of 'Page Setup' menuItem.
  661. #                    pPrinter -             
  662. #                                        0 - Don't do default Printer()
  663. #                                        1 - Do default Printer()
  664. #                                        list - list containing ordinality of 'Print' menuItem. 
  665. #                    pQuit -                
  666. #                                        0 - Don't call Quit() Task 
  667. #                                        1 - Select 'Quit' - hard coded
  668. #                                        2 - KeyEq('q');
  669. # Returns:            None
  670. #
  671. # Example:            DoCloseApp(1,2)
  672. #=======================================================================
  673. # History:
  674. # KTA    7/14/93 International support: can pass in pSaveRevert as a list of 
  675. #                menuitems for saveAs and Revert. Also for pPageSetup, and pPrinter
  676. # KTA    9/10/93 AboutBox was not being called if pDismissAboutBox was a string
  677. # KTA    12/1/93 Generic output line "About Box is not being tested" (bug 1121688)
  678. # KTA    12/1/93 Deleted call to DoSpecialTest() and added hooks gDoCloseAppHook1, 
  679. #                gDoCloseAppHook2, gDoCloseAppHook3
  680. #########################################################################
  681. TASK DoCloseApp(pSaveRevert := 0, pDismissAboutBox := 0, pPageSetup := 1, pPrinter := 1, pQuit := 1)
  682. begin
  683.     global gFileName, gApptitle;
  684.     RevertMI := '';
  685.     SaveAsMenu := 1;
  686.  
  687.     If (global gDoCloseAppHook1)
  688.         call (gDoCloseAppHook1);
  689.  
  690.     if(TypeOf(pSaveRevert) = 'list')
  691.     begin
  692.         SaveAsMenu := pSaveRevert[2];
  693.         if(TypeOf(pSaveRevert[1]) = 'list')
  694.         begin
  695.             RevertMI := pSaveRevert[1];     # Set RevertMI to the menuItem was passed in. 
  696.             pSaveRevert:= 1;             # if a menuItem was passed in Revert must be true
  697.         end;
  698.         else
  699.             pSaveRevert := pSaveRevert[1];
  700.     end;
  701.     
  702.     if (pSaveRevert > 0)                    # if app supports revert
  703.         DoFiles(3,,SaveAsMenu,,RevertMI);                    # save as/Cancel, save, modify, revert
  704.     else if (pSaveRevert = 0)                    # else if 0, no revert
  705.     begin
  706.         logstr("There is no revert in '{gApptitle}'");
  707.         DoFiles(5,,SaveAsMenu);                    # save as/Cancel, save
  708.     end;                                        # if pSaveRevert < 0, do nothing
  709.     
  710.     if not(pDismissAboutBox = -1)                        # test about box
  711.         AboutBox(pDismissAboutBox);
  712.     else
  713.         logstr("About Box is not being tested");
  714.     
  715.     if (TypeOf(pPageSetup) = 'list')        # Support for (intl)
  716.         PageSetup(, pPageSetup);                            # Page Setup Testing
  717.     else if (pPageSetup)
  718.         PageSetup();                            # Page Setup Testing
  719.     
  720.     if (TypeOf(pPrinter) = 'list')        # Support for (intl)
  721.         Printer(pPrinter);                                # Print Testing
  722.     else if (pPrinter)
  723.         Printer();                                # Print Testing
  724.     
  725.     
  726.     If (global gDoCloseAppHook2)
  727.         call (gDoCloseAppHook2);
  728.     
  729.     if not (pSaveRevert < 0)                        # if haven't done any save above
  730.         SaveAs(gFileName,0,SaveAsMenu);                    # Save as, new file
  731.     
  732.     if (pQuit)
  733.         Quit(,,pQuit);                            # Quit
  734.     
  735.     If (global gDoCloseAppHook3)
  736.         call (gDoCloseAppHook3);
  737. end;